package service

import (
	"github.com/gin-gonic/gin"
	"satis-go/app/collector/model"
	"satis-go/base/collector"
	"strings"
)

type IncludesService struct {
	collector.IncludesServiceHTTPServer
}

func (i *IncludesService) Add(ctx *gin.Context, req *collector.IncludesServiceAddReq) (rsp *collector.IncludesServiceAddRsp, err error) {
	rsp = &collector.IncludesServiceAddRsp{}
	rsp.Data, err = (&model.Includes{}).Add(ctx, strings.Trim(req.Name, " "))

	return
}

func (i *IncludesService) Del(ctx *gin.Context, req *collector.IncludesServiceDelReq) (rsp *collector.IncludesServiceDelRsp, err error) {
	err = (&model.Includes{}).DelById(ctx, req.Id)
	return
}

func (i *IncludesService) All(ctx *gin.Context, req *collector.IncludesServiceAllReq) (rsp *collector.IncludesServiceAllRsp, err error) {
	rsp = &collector.IncludesServiceAllRsp{}
	rsp.Data, err = (&model.Includes{}).All(ctx)
	return
}
